<template>
	<view class="pages">

		<view @click="goLink(`/pages/detail/video?id=${item.id}&class=${item.class}`)" class="card m-b-30"
			v-for="(item,index) in studyList" :key="index">
			<view class="flex-between-column flex-1">
				<view class="u-line-2">{{item.title}}</view>
				<view class="flex-1"></view>
				<view class="col-9 f-26">{{item.time}}</view>
			</view>
			<image :src="item.image" mode="widthFix"></image>
		</view>
		<u-loadmore :status="status" loadingText="正在加载中,上下滑动重新加载" />
		<u-back-top :scrollTop="scrollTop" bottom="100" :customStyle="{'background-color':'#2979ff'}" :iconStyle="{
				'fontSize': '40rpx',
				'color':'#FFF' }"></u-back-top>
	</view>
</template>

<script>
	import {
		getStudyListDetail
	} from '@/api/list.js'
	export default {
		onLoad() {
			this.getStudyList()
		},
		onReachBottom() {
			this.getStudyList()
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		data() {
			return {
				status: 'nomore',
				studyList: [],
				scrollTop: 0,
				page: 1
			}
		},
		methods: {
			async getStudyList() {
				this.status = 'loading'
				const res = await getStudyListDetail({
					page: this.page,
					limit: 8,
				})
				this.status = 'nomore'
				if (res.code === 200) {
					if (res.data.length === 0) return
					this.page++
					this.studyList.push(...res.data)
				}
			}
		}
	}
</script>


<style lang="scss" scoped>
	.pages {
		padding: 30rpx;
	}

	.card {
		display: flex;
		justify-content: space-between;
		padding: 20rpx;
		border-radius: 20rpx;
		background-color: rgba(255, 255, 255, 0.8);

		image {
			margin-left: 30rpx;
			width: 300rpx;
			height: auto;
			border-radius: 12rpx;
		}
	}
</style>
